<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>回调页面</title>

  <!--集成vue和axios，还要axios全局配置（导入common.js）-->
  <!--script src方式引入vue和axios-->
  <script src="./plugins/axios.js"></script>
  <script src="./plugins/vue.js"></script>
  <script src="./element-ui/lib/index.js"></script>
  <link rel="stylesheet" href="./element-ui/lib/theme-chalk/index.css">
  <!--全局配置，以后只要用vue+axios的页面都引入common.js-->
  <script src="common/common.js"></script>
</head>
<body>
<div id="myDiv">

</div>
<script type="text/javascript">
  new Vue({
    el:"#myDiv",
    mounted(){
      //解析参数对象
      let url = location.href;
      let paramObj = parseUrlParams2Obj(url);

      //获取发送请求参数
      let params = {"code":paramObj.code};
      //发起微信登录请求
      this.$http.post("/login/wechat",params).then(res=>{
        if (res.data.msg == 'NoBind'){
          location.href = "/bind.html?unionid=" + res.data.data
        }else {
          location.href = "/index.html"
          localStorage.setItem("token",res.data.data.token);
          //把对象转换为json字符串存放
          localStorage.setItem("loginInfo",JSON.stringify(res.data.data.logininfo));
        }
       })
    }
  });
</script>
</body>
</html>